package synchro;

/**
 *
 * @author boomar
 */
public class SemBinaire {

    public int Scpt = 1;    // ?Donne ou laisse la main

    public void E0(int val) {
        Scpt = val;
    }//end E0(int val)

    public synchronized void V() {
        Scpt++;
        if (Scpt <= 0) {
            notify();//Debloquer
        }//end if
    }//end V()

    public synchronized void P() {
        Scpt--;
        if (Scpt < 0) {
            try {
                wait();//Bloquer
            } catch (Exception e) {
            }//end catch
        }//end if
    }//end P()
}
